/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package model;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;

/**
 *
 * @author yann
 */
@Entity
@NamedQueries({
    @NamedQuery(name = "findChangeRate", query = "SELECT c FROM Currency c WHERE c.fromCurrency LIKE :currencyName"),
    @NamedQuery(name = "findStoredCurrencies", query = "SELECT c FROM Currency c"),
    })
public class Currency implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Integer id;
    @Column(name = "fromCurrency", nullable = false)
    private String fromCurrency;
    @Column(name = "change", nullable = false)
    private double change;

    public Currency() {
    }

    public Currency(String fromCurrency, double change) {
        this.fromCurrency = fromCurrency;
        this.change = change;
    }

    public void setFromCurrency(String currency) {
        this.fromCurrency = currency;
    }

    public String getFromCurrency() {
        return this.fromCurrency;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public double getChange() {
        return change;
    }

    public void setChange(double change) {
        this.change = change;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Currency)) {
            return false;
        }
        Currency other = (Currency) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "model.Currency[ id=" + id + " ]";
    }
}
